home *** CD-ROM | disk | FTP | other *** search
- Path: newton.uncg.edu!news
- From: "Monica M. Chew" <mmchew@hamlet.uncg.edu>
- Newsgroups: comp.lang.c
- Subject: This is an unreasonable request
- Date: 2 Jan 1996 14:47:55 GMT
- Organization: University of North Carolina at Greensboro
- Message-ID: <4cbgir$mks@newton.uncg.edu>
- NNTP-Posting-Host: shannon.uncg.edu
- Mime-Version: 1.0
- Content-Type: multipart/mixed;
- boundary="-------------------------------21923304281857"
- X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.4 sun4m)
- X-URL: file:/afs/uncg.edu/user/m/mmchew/help_me.txt
-
- This is a multi-part message in MIME format.
-
- ---------------------------------21923304281857
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
-
- --
- mmchew@hamlet.uncg.edu
-
- ---------------------------------21923304281857
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain
-
- Hello to all the gurus out there,
-
- I'm trying to convert Sparc assembly to DEC Alpha assembly with little
- success. I am hoping that someone loves this kind of stuff and will
- be able to code the following in DEC Alpha with no problem:
-
-
- #ifdef sparc
- /**************************************************************************************\
- *************************** SPARC Assembley Language Macros ****************************
- \**************************************************************************************/
-
- /*
- * SAVE_CONTEXT is invoked from within ContextSwitchto or ContextSwitchback. *
- * Both of these routines are treated as non-leaf procedures by the SPARC C *
- * compiler. Consequently, the only registers that need to be saved are the *
- * frame pointer (%i6) and the return address (%i7). *
- * *
- * 0x03 is the ST_FLUSH_WINDOWS software trap. It causes all of the *
- * registers sets cached in register windows to be flushed to memory (each *
- * register set being stored in the appropriate frame on the user stack) and *
- * the WIM register is adjusted so that when the process to which control is *
- * being switched executes a return from whatever procedure it is currently *
- * in, a trap occurs to cause the previous register set to be read from *
- * memory. *
- * */
-
- #define SAVE_CONTEXT(addr) \
- YS__CxtPtr = addr; \
- asm("sethi %hi(YS__CxtPtr),%o0"); \
- asm("ld [%o0+%lo(YS__CxtPtr)],%o0"); \
- asm("std %i6,[%o0+8]"); \
- asm("ta 0x03");
-
- /* *
- * RESTORE_CONTEXT restores the frame pointer and stack pointer that were *
- * saved in the new process context at the last time control was *
- * transferred from the new context. At the completion of RESTORE_CONTEXT, *
- * execution within ContextSwitchto or ContextSwitchback continues. When *
- * either of these routines terminate, it is the return address that has *
- * just been restored by RESTORE_CONTEXT that determines that control *
- * returns to the instruction in the new process just after its last call *
- * to ContextSwitchto or ContextSwitchback. *
- * */
-
- #define RESTORE_CONTEXT(addr) \
- YS__CxtPtr = addr; \
- asm("sethi %hi(YS__CxtPtr),%o0"); \
- asm("ld [%o0+%lo(YS__CxtPtr)],%o0"); \
- asm("ldd [%o0+8],%i6");
-
- /* *
- * INITIAL_CONTEXT is necessary because the first time control is *
- * transferred to a new context, there is no saved return address to be *
- * used. We cannot simply put the entry point for ContextTerminate as the *
- * return address and use RESTORE_CONTEXT because control would then never *
- * be transferred to the entry point for the new context. Instead, we must *
- * put the entry point for ContextTerminate in %o7 to be used as the return *
- * address when the process running in the new context terminates. We must *
- * also set up the frame pointer and stack pointer for the new context (see *
- * InitContext() in machdep.c). Finally, we use the entry point of the *
- * new process (which was stored in the context descriptor) to jump *
- * to the start of the new context root procedure. *
- * */
-
- #define INITIAL_CONTEXT(addr) \
- YS__CxtPtr = addr; \
- asm("sethi %hi(YS__CxtPtr),%o0"); \
- asm("ld [%o0+%lo(YS__CxtPtr)],%o0"); \
- asm("ld [%o0+12],%o7"); \
- asm("ld [%o0+12],%i7"); \
- asm("ld [%o0+16],%o1"); \
- asm("ld [%o0+8],%i6"); \
- asm("add %i6,104,%i6"); \
- asm("ld [%o0+8],%o6"); \
- asm("jmpl %o1,%o2"); \
- asm("nop");
-
- #endif /*************************** End of SPARC code *********************************/
-
- Many thanks for your time. Please send replies and suggestions to
-
- mmchew@hamlet.uncg.edu
-
- Thanks,
- Monica
-
-
-
-
- ---------------------------------21923304281857--
-